package gov.gfbzb.advice.exception;

import gov.gfbzb.advice.util.Result;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;


/**
 * 全局自定义异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    // 处理特定的异常
    @ExceptionHandler(BusinessException.class)
    public ResponseEntity<Result> handleBusinessException(BusinessException ex) {
        return new ResponseEntity<>(Result.error(ex.getCode(),ex.getMessage(),null),HttpStatus.OK);
    }
}
